package com.example.demo.controller;

/**
 *
 */

import com.example.demo.entity.News;
import com.example.demo.service.NewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/general")
@Api(tags = "通用模块") // 控制器标签
public class GeneralController {

    @Autowired
    NewsService newsService;


    @GetMapping("/getAllPlayers")
    @ApiOperation("资讯页面-分页查询所有")
    public List<News> getAllPlayers(@RequestParam(defaultValue = "0") int page,
                                    @RequestParam(defaultValue = "10") int size) {
        return newsService.getAll(PageRequest.of(page, size));
    }

    @GetMapping("/getById")
    @ApiOperation("资讯页面-根据id查询")
    public News getById(Integer id) {
        return newsService.getById(id);
    }
}
